package com.woniu.controller;

import com.woniu.entity.RbacManager;
import com.woniu.entity.ResponseEntity;
import com.woniu.service.RbacManagerService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Rain
 * @Description :
 * @date 2022/09/01 14:34
 */
@RequiresRoles("admin")
@RestController
@CrossOrigin
@RequestMapping("/rbacManager")
public class RbacManagerController {

    @Autowired
    RbacManagerService rbacManagerService;

    @PostMapping("/findAll/{pageNum}/{pageSize}")
    public ResponseEntity findAll(@PathVariable("pageNum") int pageNum,
                                  @PathVariable("pageSize") int pageSize,
                                  @RequestBody RbacManager rbac) {

        return rbacManagerService.findAll(pageNum,pageSize,rbac);
    }

    @RequestMapping("/deleteOne")
    public ResponseEntity deleteOne(int id) {
        return rbacManagerService.deleteOne(id);
    }

    @PostMapping("/addOne")
    public ResponseEntity addOne(@RequestBody RbacManager rbac) {
        return rbacManagerService.addOne(rbac);
    }

    @PostMapping("/editOne")
    public ResponseEntity editOne(@RequestBody RbacManager rbac) {
        return rbacManagerService.editOne(rbac);
    }

    @PostMapping("/editOneStatus")
    public ResponseEntity editOneStatus(@RequestBody RbacManager rbac) {
        return rbacManagerService.editOneStatus(rbac);
    }



    @GetMapping("/initPwd/{id}")
    public ResponseEntity initPwd(@PathVariable int id) {
        return rbacManagerService.initPwd(id);
    }
}
